package com.yuan.Controller.user;

import com.yuan.Service.DishService;
import com.yuan.constant.StatusConstant;
import com.yuan.entity.Dish;
import com.yuan.result.Result;
import com.yuan.vo.DishVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userDishController")
@RequestMapping("/user/dish")
@Slf4j
@Tag(name = "C端-菜品浏览接口")
@RequiredArgsConstructor
public class DishController {

    private final DishService dishService;
//private final


    //根据分类id查询菜品
    @GetMapping("/list")
    @Operation(description = "根据分类id查询菜品")
    public Result<List<DishVO>> list(Long categoryId) {


        Dish dish = new Dish();

        dish.setCategoryId(categoryId);
        dish.setStatus(StatusConstant.ENABLE);//查询起售中的菜品

        List<DishVO> list = dishService.listWithFlavor(dish);
        return Result.success(list);

    }

}
